<template>
	<div class="like-list">
		<!-- 没有商品数据显示否则隐藏-->
		<div class="empty" v-if="classifyList.length == 0"><p>商品正在上架中...</p><img src="../../assets/img/onTheShelf.png"/></div>
		<!-- 有商品数据显示否则隐藏 -->
		<div v-else class="f-row-between">
			<div @click="todetails(item.goods_id)" class="like-item" v-for="item in classifyList" :key="item.goods_id" >
				<div :style="{height :imgHeight + 'px'}">
					<van-image @load="Isload = false" lazy-load :src="item.goods_thumb">
							<van-loading v-if="Isload" color="#07c160" />
					</van-image>
				</div>
				<p v-cloak>{{item.goods_name}}</p>
				<p v-cloak>{{item.goods_desc}}</p>
				<p v-cloak>￥{{item.price}}</p>
			</div>
		</div>		
	</div>
</template>

<script>
	export default {
		props : ['classifyList'],
		data(){
			return {
				Isload : true,
			}
		},
		
		computed:{
			imgHeight(){
				let windowW = document.documentElement.clientWidth - 24;
				return windowW * 0.49;
			},
		},
		
		methods : {
			todetails(val){
				this.$router.push({path : 'details', query:{'goods_id' : val}});
			},
		},
	}
</script>

<style scoped lang="less">
	.like-list{
		.empty{
			text-align: center;
			font-size: 20px;
			color: #07c160;
			padding-top: 30px;
			img{
				width:100px;
				margin-top: 20px;
				
			}
		}
		.f-row-between{
			flex-wrap: wrap;
			
			.like-item{
				background-color: #fff;
				margin-bottom: 12px;
				width:49%;
				height: 300px;
				font-size: 13px;
				
				p{
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
					margin: 10px 0;
				}
				p:nth-child(4){
					font-size: 16px;
					font-weight: bold;
					color : #4ABF5C;
					margin-top: 20px;
				}
			}
		}
	
		.more{
			text-align: center;
			line-height: 40px;
			color:#666;
			font-size: 14px;
		}
	}
	
</style>
